<?php
declare (strict_types = 1);
namespace app\admin\validate\content\agreement;

use think\Validate;

/**
 * 协议数据验证
 */
class Agreement extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'      => 'require',
        'key'     => ['require', 'regex' => "/^[\d\.\w]+$/", 'length:1,100'],
        'title'   => 'require|length:1,200',
        'content' => 'require',
        'remark'  => 'length:1,100',

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'key.require'   => '请输入协议标识',
        'key.regex'     => '协议标识由字母和英文点(`.`)组成',
        'key.length'    => '协议标识为1-100个字符',
        'title.require' => '请输入协议名称',
        'title.length'  => '协议名称为1-200个字符',
        'content'       => '请输入协议内容',
        'remark'        => '协议备注为1-100个字符',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create' => ['key', 'title', 'content', 'remark'],
        'edit'   => ['id', 'key', 'title', 'content', 'remark'],
    ];

}
